<?php echo $this->Html->script('jquery.autogrow-textarea'); ?>

<?php
        
	echo $this->Form->create('Notice', array('id' => 'formUpdateNotice'));
	echo $this->Form->input( 'message', array( 'label' => false, 'classs' => 'noticemessage', 'id' => 'message' ));
	echo $this->Form->hidden('reply_to', array('id' => 'inreplyto', 'value' => ''));
	echo $this->Html->div('button-update',
                
                $this->Form->button('Update',
			array(
                            'type' => 'button',
                            'class' => 'submit white',
                            'id' => 'button-update'
			))
                );
	echo $this->Form->end();
?>
<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function () {
        
        $('textarea').autogrow();
        $("#button-update").bind("click", function (event) {
            if($('#message').val().length < 1){
                return false;
            }

            $.ajax({
                async:false,
                data:$("#button-update").closest("form").serialize(),
                dataType:"html",
                beforeSend:function (){ var message = $('#message').val(); if( message.length > 140){message = message.substring(0, 140) + '...'} $('#message_latest').html(message);},
                success:function (data, textStatus) {updateForm(data)},
                type:"post",
                url:"<?php echo Router::url(array('controller' => 'notices', 'action' => 'update')) ?>"
            });
        });
    });
    //]]>
</script>
